package com.cms.common.model.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseResult<T> implements Serializable {
    private Integer code;
    private String msg;
    private T data;

    public static <T> ResponseResult success(T data) {
        ResponseResult resultVO = new ResponseResult(
                ResponseCodeEnum.SUCCESS.getCode(),
                ResponseCodeEnum.SUCCESS.getMsg(),
                data);
        return resultVO;
    }

    public static <T> ResponseResult success(String message, T data) {
        ResponseResult resultVO = new ResponseResult(
                ResponseCodeEnum.SUCCESS.getCode(),
                message,
                data);
        return resultVO;
    }

    public static <T> ResponseResult<T> fail(String message) {
        return new ResponseResult<T>(
                ResponseCodeEnum.FAIL.getCode(),
                message,
                null);
    }

}

